$(ꞌ.navbar-toggleꞌ).click   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 30
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 23
nc 2
nop 0
dl 0
loc 30
rs 9.328
c 1
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A ick 0 4 1
A ick 0 8 1
1
/*!
2
3
 =========================================================
4
 * Paper Dashboard 2 - v2.0.0
5
 =========================================================
6
7
 * Product Page: https://www.creative-tim.com/product/paper-dashboard-2
8
 * Copyright 2018 Creative Tim (http://www.creative-tim.com)
9
10
 * Designed by www.invisionapp.com Coded by www.creative-tim.com
11
12
 =========================================================
13
14
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15
16
 */
17
18
(function() {
19
  isWindows = navigator.platform.indexOf('Win') > -1 ? true : false;
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable isWindows seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.isWindows.
Loading history...
20
21
  if (isWindows) {
22
    // if we are on windows OS we activate the perfectScrollbar function
23
    $('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar();
24
25
    $('html').addClass('perfect-scrollbar-on');
26
  } else {
27
    $('html').addClass('perfect-scrollbar-off');
28
  }
29
})();
30
31
transparent = true;
0 ignored issues
show
Bug introduced by
The variable transparent seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.transparent.
Loading history...
32
transparentDemo = true;
0 ignored issues
show
Bug introduced by
The variable transparentDemo seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.transparentDemo.
Loading history...
33
fixedTop = false;
0 ignored issues
show
Bug introduced by
The variable fixedTop seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.fixedTop.
Loading history...
34
35
navbar_initialized = false;
0 ignored issues
show
Bug introduced by
The variable navbar_initialized seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.navbar_initialized.
Loading history...
36
backgroundOrange = false;
0 ignored issues
show
Bug introduced by
The variable backgroundOrange seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.backgroundOrange.
Loading history...
37
sidebar_mini_active = false;
0 ignored issues
show
Bug introduced by
The variable sidebar_mini_active seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.sidebar_mini_active.
Loading history...
38
toggle_initialized = false;
0 ignored issues
show
Bug introduced by
The variable toggle_initialized seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.toggle_initialized.
Loading history...
39
40
seq = 0, delays = 80, durations = 500;
0 ignored issues
show
Bug introduced by
The variable delays seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.delays.
Loading history...
Bug introduced by
The variable durations seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.durations.
Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Bug introduced by
The variable seq seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.seq.
Loading history...
41
seq2 = 0, delays2 = 80, durations2 = 500;
0 ignored issues
show
Bug introduced by
The variable durations2 seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.durations2.
Loading history...
Bug introduced by
The variable delays2 seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.delays2.
Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Bug introduced by
The variable seq2 seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.seq2.
Loading history...
42
43
$(document).ready(function() {
44
45
  if ($('.full-screen-map').length == 0 && $('.bd-docs').length == 0) {
0 ignored issues
show
Best Practice introduced by
Comparing $(".bd-docs").length to 0 using the == operator is not safe. Consider using === instead.
Loading history...
Best Practice introduced by
Comparing $(".full-screen-map").length to 0 using the == operator is not safe. Consider using === instead.
Loading history...
46
    // On click navbar-collapse the menu will be white not transparent
47
    $('.collapse').on('show.bs.collapse', function() {
48
      $(this).closest('.navbar').removeClass('navbar-transparent').addClass('bg-white');
49
    }).on('hide.bs.collapse', function() {
50
      $(this).closest('.navbar').addClass('navbar-transparent').removeClass('bg-white');
51
    });
52
  }
53
54
  paperDashboard.initMinimizeSidebar();
0 ignored issues
show
Bug introduced by
The variable paperDashboard seems to be never declared. If this is a global, consider adding a /** global: paperDashboard */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
55
56
  $navbar = $('.navbar[color-on-scroll]');
0 ignored issues
show
Bug introduced by
The variable $navbar seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$navbar.
Loading history...
57
  scroll_distance = $navbar.attr('color-on-scroll') || 500;
0 ignored issues
show
Bug introduced by
The variable scroll_distance seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.scroll_distance.
Loading history...
58
59
  // Check if we have the class "navbar-color-on-scroll" then add the function to remove the class "navbar-transparent" so it will transform to a plain color.
60
  if ($('.navbar[color-on-scroll]').length != 0) {
0 ignored issues
show
Best Practice introduced by
Comparing $(".navbar[color-on-scroll]").length to 0 using the != operator is not safe. Consider using !== instead.
Loading history...
61
    paperDashboard.checkScrollForTransparentNavbar();
62
    $(window).on('scroll', paperDashboard.checkScrollForTransparentNavbar)
63
  }
64
65
  $('.form-control').on("focus", function() {
66
    $(this).parent('.input-group').addClass("input-group-focus");
67
  }).on("blur", function() {
68
    $(this).parent(".input-group").removeClass("input-group-focus");
69
  });
70
71
  // Activate bootstrapSwitch
72
  $('.bootstrap-switch').each(function() {
73
    $this = $(this);
0 ignored issues
show
Bug introduced by
The variable $this seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$this.
Loading history...
74
    data_on_label = $this.data('on-label') || '';
0 ignored issues
show
Bug introduced by
The variable data_on_label seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.data_on_label.
Loading history...
75
    data_off_label = $this.data('off-label') || '';
0 ignored issues
show
Bug introduced by
The variable data_off_label seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.data_off_label.
Loading history...
76
77
    $this.bootstrapSwitch({
78
      onText: data_on_label,
79
      offText: data_off_label
80
    });
81
  });
82
});
83
84
$(document).on('click', '.navbar-toggle', function() {
85
  $toggle = $(this);
0 ignored issues
show
Bug introduced by
The variable $toggle seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$toggle.
Loading history...
86
87
  if (paperDashboard.misc.navbar_menu_visible == 1) {
0 ignored issues
show
Best Practice introduced by
Comparing paperDashboard.misc.navbar_menu_visible to 1 using the == operator is not safe. Consider using === instead.
Loading history...
Bug introduced by
The variable paperDashboard seems to be never declared. If this is a global, consider adding a /** global: paperDashboard */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
88
    $('html').removeClass('nav-open');
89
    paperDashboard.misc.navbar_menu_visible = 0;
90
    setTimeout(function() {
91
      $toggle.removeClass('toggled');
92
      $('#bodyClick').remove();
93
    }, 550);
94
95
  } else {
96
    setTimeout(function() {
97
      $toggle.addClass('toggled');
98
    }, 580);
99
100
    div = '<div id="bodyClick"></div>';
0 ignored issues
show
Bug introduced by
The variable div seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.div.
Loading history...
101
    $(div).appendTo('body').click(function() {
102
      $('html').removeClass('nav-open');
103
      paperDashboard.misc.navbar_menu_visible = 0;
0 ignored issues
show
Bug introduced by
The variable paperDashboard seems to be never declared. If this is a global, consider adding a /** global: paperDashboard */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
104
      setTimeout(function() {
105
        $toggle.removeClass('toggled');
106
        $('#bodyClick').remove();
107
      }, 550);
108
    });
109
110
    $('html').addClass('nav-open');
111
    paperDashboard.misc.navbar_menu_visible = 1;
112
  }
113
});
114
115
$(window).resize(function() {
116
  // reset the seq for charts drawing animations
117
  seq = seq2 = 0;
0 ignored issues
show
Bug introduced by
The variable seq seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.seq.
Loading history...
Bug introduced by
The variable seq2 seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.seq2.
Loading history...
118
119
  if ($('.full-screen-map').length == 0 && $('.bd-docs').length == 0) {
0 ignored issues
show
Best Practice introduced by
Comparing $(".bd-docs").length to 0 using the == operator is not safe. Consider using === instead.
Loading history...
Best Practice introduced by
Comparing $(".full-screen-map").length to 0 using the == operator is not safe. Consider using === instead.
Loading history...
120
    $navbar = $('.navbar');
0 ignored issues
show
Bug introduced by
The variable $navbar seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$navbar.
Loading history...
121
    isExpanded = $('.navbar').find('[data-toggle="collapse"]').attr("aria-expanded");
0 ignored issues
show
Bug introduced by
The variable isExpanded seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.isExpanded.
Loading history...
122
    if ($navbar.hasClass('bg-white') && $(window).width() > 991) {
123
      $navbar.removeClass('bg-white').addClass('navbar-transparent');
124
    } else if ($navbar.hasClass('navbar-transparent') && $(window).width() < 991 && isExpanded != "false") {
125
      $navbar.addClass('bg-white').removeClass('navbar-transparent');
126
    }
127
  }
128
});
129
130
paperDashboard = {
0 ignored issues
show
Bug introduced by
The variable paperDashboard seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.paperDashboard.
Loading history...
131
  misc: {
132
    navbar_menu_visible: 0
133
  },
134
135
  initMinimizeSidebar: function() {
136
    if ($('.sidebar-mini').length != 0) {
0 ignored issues
show
Best Practice introduced by
Comparing $(".sidebar-mini").length to 0 using the != operator is not safe. Consider using !== instead.
Loading history...
137
      sidebar_mini_active = true;
0 ignored issues
show
Bug introduced by
The variable sidebar_mini_active seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.sidebar_mini_active.
Loading history...
138
    }
139
140
    $('#minimizeSidebar').click(function() {
141
      var $btn = $(this);
0 ignored issues
show
Unused Code introduced by
The variable $btn seems to be never used. Consider removing it.
Loading history...
142
143
      if (sidebar_mini_active == true) {
0 ignored issues
show
Best Practice introduced by
Comparing sidebar_mini_active to true using the == operator is not safe. Consider using === instead.
Loading history...
144
        $('body').addClass('sidebar-mini');
145
        sidebar_mini_active = true;
0 ignored issues
show
Bug introduced by
The variable sidebar_mini_active seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.sidebar_mini_active.
Loading history...
146
        paperDashboard.showSidebarMessage('Sidebar mini activated...');
0 ignored issues
show
Bug introduced by
The variable paperDashboard seems to be never declared. If this is a global, consider adding a /** global: paperDashboard */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
147
      } else {
148
        $('body').removeClass('sidebar-mini');
149
        sidebar_mini_active = false;
150
        paperDashboard.showSidebarMessage('Sidebar mini deactivated...');
151
      }
152
153
      // we simulate the window Resize so the charts will get updated in realtime.
154
      var simulateWindowResize = setInterval(function() {
155
        window.dispatchEvent(new Event('resize'));
0 ignored issues
show
Bug introduced by
The variable Event seems to be never declared. If this is a global, consider adding a /** global: Event */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
156
      }, 180);
157
158
      // we stop the simulation of Window Resize after the animations are completed
159
      setTimeout(function() {
160
        clearInterval(simulateWindowResize);
161
      }, 1000);
162
    });
163
  },
164
165
  showSidebarMessage: function(message) {
166
    try {
167
      $.notify({
168
        icon: "now-ui-icons ui-1_bell-53",
169
        message: message
170
      }, {
171
        type: 'info',
172
        timer: 4000,
173
        placement: {
174
          from: 'top',
175
          align: 'right'
176
        }
177
      });
178
    } catch (e) {
179
      console.log('Notify library is missing, please make sure you have the notifications library added.');
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
180
    }
181
182
  }
183
184
};
185
186
function hexToRGB(hex, alpha) {
187
  var r = parseInt(hex.slice(1, 3), 16),
188
    g = parseInt(hex.slice(3, 5), 16),
189
    b = parseInt(hex.slice(5, 7), 16);
190
191
  if (alpha) {
192
    return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")";
193
  } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
194
    return "rgb(" + r + ", " + g + ", " + b + ")";
195
  }
196
}